"""mysite1 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
# re_path可以进行正则匹配
from django.urls import path, re_path
# 导入视图模块views.py
from . import views
# 路由配置
urlpatterns = [
    path('admin/', admin.site.urls),
    # http://127.0.0.1:8000/hello
    # 如果客户端请求路由是hello，通过一个函数来处理请求
    path('hello', views.hello_view),
    path('', views.index_view),
    path('page/1', views.page1_view),
    path('page/2', views.page2_view),
    # 通过转换器可以动态传递值
    path('page/<int:pno>', views.pagen_view),
    # http://127.0.0.1:8000/login/用户名/密码
    path('login/<str:username>/<str:password>', views.login_view),
    path('<int:num1>/<str:op>/<int:num2>', views.calc_view),
    # http://127.0.0.1:8000/phone/手机号码
    # 正则表达式为命名分组模式 (?P<name>pattern)
    re_path(r'^phone/(?P<tel>1[3-9]\d{9})$', views.phone_view),
    re_path(r'^birthday/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<date>\d{1,2})$', views.birthday_view),
    re_path(r'^email/(?P<email>[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)/(?P<num>\d{6})$', views.email_view)



]
